package com.hup.utils.commons.start;

import lombok.Getter;
import lombok.Setter;

/**
 * 退出执行器:实现全局'执行退出逻辑'功能;
 * @apiNote
 * SpringContext.getBean(SimpleExitHandler.class).setExitAction();<br>
 * SpringContext.getBean(SimpleExitHandler.class).doExit();
 * @author hugan
 * @date 2020/4/5
 */
public class SimpleExitHandler {

    /*
    @Bean
    public SimpleExitHandler exitHandler() {
        return new SimpleExitHandler();
    }
     */

    /**
     * 退出程序前的逻辑
     */
    @Setter
    private Runnable exitAction;
    /**
     * 是否正在退出程序,由业务代码控制的,本类不处理!
     */
    @Getter
    @Setter
    private boolean exiting;

    public void doExit() {
        exitAction.run();
    }

}
